package com.aat.restful.resteasy.server;

import org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer;
import org.jboss.resteasy.spi.ResteasyDeployment;
import org.jboss.resteasy.spi.ResteasyProviderFactory;

import com.alibaba.fastjson.support.jaxrs.FastJsonProvider;

/**
 * @author wux
 * @mail wux@sense.com.cn
 * @date 2016年9月9日 上午9:10:38
 * @version 1.0
 * @update no
 * @info 服务启动入口，日志级别DEBUG；
 */

public class App {

	public static void main(String[] args) {

		String host = "0.0.0.0";
		String rootResourcePath = "";
		int port = Integer.parseInt("56789");

		// resteasy
		ResteasyDeployment deployment = new ResteasyDeployment();
		deployment.setApplication(new SacnApiPackage().setScanPackage("com.aat.restful.resteasy.itf"));

		// provider
		ResteasyProviderFactory providerFactory = new ResteasyProviderFactory();
		providerFactory.registerProvider(FastJsonProvider.class, true);
		deployment.setProviderFactory(providerFactory);

		NettyJaxrsServer nettyServer = new NettyJaxrsServer();
		nettyServer.setDeployment(deployment);
		nettyServer.setHostname(host);
		nettyServer.setPort(port);
		nettyServer.setRootResourcePath(rootResourcePath);
		nettyServer.setSecurityDomain(null);
		nettyServer.start();
	}

}
